package com.yunjinsuke.recharge.redis;

public class RedisKeyUtil {

    /**
     * 订单分组
     */
    public static final int RECHARGE_ORDER_LIST_SIZE = 6;

    /**
     * 商户初始化成功标识
     */
    public static final String MERCHANT_INIT_SUCCESS = "merchant-init-success";

    /**
     * 锁-充值订单列表
     */
    private static final String LOCK_RECHARGE_ORDER_LIST = "lock-recharge-order:lock:list";

    /**
     * 充值订单列表
     */
    private static final String RECHARGE_ORDER_LIST = "recharge-order:list";

    /**
     * 商户标识
     */
    private static final String MERCHANT = "merchant";

    /**
     * APP标识
     */
    private static final String APP = "app";

    /**
     * 访问Token标识
     */
    private static final String ACCESS_TOKEN = "access-token";

    /**
     * 订单
     */
    public static final String QUERY_ORDER = "query-order";

    public static String merchantKey(String mchId, String mchKey) {
        return String.format("%s:%s-%s", MERCHANT, mchId, mchKey);
    }

    public static String appKey(String appId) {
        return String.format("%s:%s", APP, appId);
    }

    public static String accessTokenKey(String accessToken) {
        return String.format("%s:%s", ACCESS_TOKEN, accessToken);
    }

    public static String queryOrderKey(String queryOrderNumber) {
        return String.format("%s:%s", QUERY_ORDER, queryOrderNumber);
    }

    public static String rechargeOrderListKey(int num) {
        return String.format("%s-%d", RECHARGE_ORDER_LIST, num);
    }

    public static String lockRechargeOrderListKey(int num) {
        return String.format("%s-%d", LOCK_RECHARGE_ORDER_LIST, num);
    }

}
